1. Field of the Invention
The present invention relates to a compiler system for a language processing program.
2. Description of Related Art
Conventionally, a computer program is developed in such a manner that a source program is created by a program developer, and the created source program is processed by a language processing program (for example, compiler) so that it it translated into a sequence of machine language instructions for a microcomputer, and the sequence of machine language instructions is installed in a memory within the microcomputer and then, executed by the microcomputer. A source program written in a high level language is translated by a compiler to be converted into an object machine language sequence.
Referring to FIG. 1, there is shown a block diagram illustrating a conventional compiler system.
In a compiler 102A, a source program 101 is analyzed by a syntax analysis part 103 so that a pre-optimization intermediate code information 104 is prepared. Thereafter, in an optimization part 105A, the intermediate code information is analyzed for optimization, so that optimization analyzed information 107 is created. With reference to the optimization analyzed information 107, the intermediate code is optimized so as to create a post-optimization intermediate code information 108. In a code generator 109A, the optimized intermediate code information 108 is converted into a sequence of machine language instructions, thereby to prepare an output file 111A.
Here, the "optimization" is to modify, eliminate and improve the intermediate code information, for the purpose of reducing the machine language instructions outputted in the code generator 109A and to elevate a performance of executing the obtained instructions. In the modification and elimination in the process of the optimization, an improved intermediate code information is required to have the same function as that of an input intermediate code information. The optimization is realized in various methods, and one example of the optimization is described in detail in Chapter 10 of Alfred V. AHO et al., "Compilers: Principles, Techniques, and Tool", Addison-Wesley Publishing Company (U.S.A), 1986, the disclosure of which is incorporated by reference in its entirety into the present application.
For example, in the optimization for common subexpressions, the result of an equivalent operation expression is held so as to avoid re-calculation, so that the size and the execution performance of the obtained sequence of machine language instructions are improved. The other optimization includes a loop optimization, a register assignment, a branch optimization, and others.
From a different viewpoint, the optimizing function can be divided into an optimization for shortening the sequence of instructions and an optimization of execution performance. The optimization for elevating the execution performance may accompany increase in the size of the obtained sequence of machine language instructions. In addition, an optimizing function can be designated by designating an option at the time of starting the compiler. For example, it is possible to start only elimination of common subexpressions selected from a plurality of optimizing functions. On the other hand, when a plurality of optimizing functions are executed in combination, it is in some cases that the size of the obtained sequence of machine language instructions is increased.
Returning to FIG. 1, the optimization part 105A of the compiler 102A produces information which is obtained by analyzing the intermediate code information 104 generated in the syntax analysis part 103 and which is necessary for performing a necessary optimization from the intermediate code information 104. In the case of the register assignment optimization, the analyzed information is the extent in which variables called "data flow information" are referenced and set. In the case of the branch optimization, the analyzed information is a position of a branch information in the intermediate code information and a position of a label in the intermediate code information. Ordinarily, this information analysis entails a long processing time.
In a compiler for a microcomputer, it is necessary to install a sequence of machine language instructions complied from the source program, into a limited ROM region provided in the microcomputer. In addition, when the installed sequence of machine language instructions are executed, it is necessary to have a sufficient execution performance. A use of a compiler is required to compile and develop the program, while designating various kinds of optimization functions in the compiler and investigating the size of the obtained machine language instruction sequence and the execution performance. The loop optimization and the inline optimization of a function, which are performed for elevating the execution performance, often increase the program size.
In some cases, the compiler outputs a machine language instruction for substituting an existing instruction for an operation instruction that is not provided in the microcomputer and/or an operation of a data length that is larger than that of the microcomputer. In other cases, the compiler performs a library call for a run time library.
One kind of optimization by compiler includes an optimization minimizing the output size of the program by calling the run time library. The code output optimization utilizing the run time library can minimize the output program size, but since the library calling is performed, the execution performance drops. A program developer is required to carry out the compile and to confirm the result, any number of times, so as to optimize the designation of the compiler, for the purpose of finally obtaining a program that has the size smaller than that of the ROM region into which the program is stored, and that has an execution performance higher than that expected by the program developer. Therefore, a greatly long time is needed. In addition, the larger the input file is, the longer the processing time accompanied by the optimization becomes. Therefore, the development time becomes further long, if the confirmation is performed many times.
Japanese Patent Application Laid-open Publication JP-A-59-20051 discloses a program execution system, in which information for optimizing the intermediate codes obtained after the syntax analysis is retained, and when the program is executed, an optimum execution code is generated on the base of the intermediate codes and the optimization information. However, this is not yet satisfactory.